<?php
/**
 * 历史导入记录服务层
 * @author zyb
 */
class holidaylogsService extends Service {

	/**
	 * @var holidaylogsDao
	 */
	private $holidaylogsDao;
	
	private function _getHolidaylogsDao(){
		return 	InitPHP::getDao("holidaylogs");
	}
	
	/**
	 * @var staffDao
	 */
	private $staffDao;
	
	private function _getStaffDao(){
		return 	InitPHP::getDao("staff");
	}
	
	/**
	 * 获取历史导入记录总数
	 * @param unknown $user_id
	 * @return unknown
	 */
	public function getlogsByStaff($staff_id){
		$logs_data = $this->_getHolidaylogsDao()->getLogsByStaff($staff_id);
 		return $logs_data;
	}
	
	/**
	 *  操作记录
	 * @param unknown $logs_data
	 */
	public function operateHolidayLogs($logs_data){
		//写入记录
		$log_result = $this->_getHolidaylogsDao()->addLogs($logs_data);
		if($log_result){
			$annual_holiday = 0;
			$tone_rests = 0;
			//增减假期
			if($logs_data['holiday_type'] == 0){
				if($logs_data['opperate_type'] == 0){
					$annual_holiday = $logs_data['days'];
				}
				else{
					$annual_holiday = 0-$logs_data['days'];
				}
			}else{
				if($logs_data['opperate_type'] == 0){
					$tone_rests = $logs_data['days'];
				}
				else{
					$tone_rests = 0-$logs_data['days'];
				}
			}
			$staff_result = $this->_getStaffDao()->operateDays($logs_data['staff_id'],$annual_holiday,$tone_rests);
			if($staff_result){
				return true;
			}
			return false;
		}
		
		return false;
		
		
		
		
	}
	


}